﻿@model EditForumTopicModel
@using Grand.Core.Domain.Forums;
@using Grand.Web.Models.Boards;
@inject IWebHelper webHelper;
@await Component.InvokeAsync("ForumBreadcrumb", new { forumId = Model.ForumId, forumTopicId = Model.Id })

<div class="page forum-edit-page">
    @if (Model.IsEdit)
    {
        <h2 class="generalTitle">@T("Forum.EditTopic")</h2>
    }
    else
    {
        <h2 class="generalTitle">@T("Forum.NewTopic")</h2>
    }
    <div asp-validation-summary="ModelOnly" class="message-error"></div>
    <input asp-for="Id" type="hidden" />
    <input asp-for="ForumId" type="hidden" />
    <div class="form-fields">
        <fieldset class="form-group">
            <label class="col-form-label">@T("Forum.ForumName"):</label>
            <strong>@Model.ForumName</strong>
        </fieldset>
        <fieldset class="form-group">
            <label class="col-form-label">@T("Forum.TopicTitle"):</label>
            <input asp-for="Subject" class="form-control forum-topic-title-text" />
            <span asp-validation-for="Subject"></span>
        </fieldset>
        <fieldset class="form-group">
            @if (Model.ForumEditor == EditorType.BBCodeEditor)
            {
                <label class="col-12 col-form-label text-sm-right">
                    @Html.BBCodeEditor(webHelper, "Text")
                </label>
            }
            <textarea asp-for="Text" class="form-control forum-post-text"></textarea>
            <span asp-validation-for="Text"></span>
        </fieldset>
        @if (Model.IsCustomerAllowedToSetTopicPriority)
        {
            <fieldset class="form-group">
                <label class="col-form-label">@T("Forum.Priority"):</label>
                @Html.DropDownList("TopicTypeId", new SelectList(Model.TopicPriorities, "Value", "Text", Model.TopicTypeId), new { @class = "custom-select" })
            </fieldset>
        }
        @if (Model.IsCustomerAllowedToSubscribe)
        {
            <fieldset class="form-group">
                <label class="custom-control custom-checkbox">
                    <input class="custom-control-input" id="Subscribed" type="checkbox" name="Subscribed" value="true" @(Model.Subscribed ? Html.Raw("checked") : Html.Raw("")) />
                    <span class="custom-control-label"></span>
                    <span class="custom-control-description">@T("Forum.NotifyWhenSomeonePostsInThisTopic")</span>
                </label>
            </fieldset>
        }
        <fieldset class="form-group">
            <input type="submit" value="@T("Forum.Submit")" class="btn btn-success submit-topic-button" />
            <input type="button" class="btn btn-outline-danger cancel-topic-button" value="@T("Forum.Cancel")" onclick="setLocation('@Url.RouteUrl("ForumSlug", new { id = Model.ForumId, slug = Model.ForumSeName })')" />
        </fieldset>
    </div>
</div>

